﻿<common:LayoutAwarePage x:Class="StoreAppLibDemo.Examples.Converter.CountConverterPage"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:ViewModel="using:StoreAppLibDemo.ViewModel"
                        xmlns:common="using:StoreAppLibDemo.Common"
                        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                        xmlns:local="using:StoreAppLibDemo.Examples.Converter"
                        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                        mc:Ignorable="d">

    <common:LayoutAwarePage.DataContext>
        <ViewModel:ConcatenationConverterPageView />
    </common:LayoutAwarePage.DataContext>

    <Grid Style="{StaticResource AppPageStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="40" />
            <RowDefinition />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Grid.Column="1"
                   Margin="0,0,50,0"
                   Source="ms-appx:///Assets/PageLogo.png" />
            <TextBlock Margin="120,0,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Bottom"
                       Style="{StaticResource HeaderTextStyle}"
                       Text="Count Converter"
                       TextWrapping="Wrap" />
            <Button Margin="36,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Bottom"
                    Click="GoBack"
                    Content="Button"
                    Style="{StaticResource BackButtonStyle}" />

        </Grid>

        <TextBlock Grid.Row="3"
                   Margin="0,0,50,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Center"
                   FontSize="9"
                   Text="Copyright ©  2012 Suresh Kumar T" />


        <Grid Grid.Row="2" Margin="120,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="125" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="30" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Grid.ColumnSpan="2"
                       Style="{StaticResource BodyTextStyle}"
                       TextWrapping="Wrap">
                <Run>Count converter finds count of all elements in a collection during data binding. The converter can count the elements within nested collections.</Run>
                <LineBreak />
                <LineBreak />
                <Run>In this example language counts are displayed from the following collection hierarchy.</Run>

            </TextBlock>
            <Border Grid.Row="2"
                    Background="White"
                    BorderBrush="#002896"
                    BorderThickness="1" />
            <TextBlock Grid.Row="2"
                       Width="115"
                       Margin="5,0,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Style="{StaticResource BodyTextBlackStyle}"
                       Text="{Binding Company.Name}"
                       TextWrapping="Wrap" />
            <ItemsControl Grid.Row="2"
                          Grid.Column="1"
                          Grid.ColumnSpan="1"
                          Width="400"
                          HorizontalAlignment="Left"
                          ItemsSource="{Binding Company.Departments}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="350" HorizontalAlignment="Left">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Border Grid.ColumnSpan="2"
                                    Background="White"
                                    BorderBrush="#002896"
                                    BorderThickness="1" />
                            <TextBlock Margin="5,0,0,0"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Top"
                                       Style="{StaticResource BodyTextBlackStyle}"
                                       Text="{Binding Name}"
                                       TextWrapping="Wrap" />
                            <ItemsControl Grid.Column="1" ItemsSource="{Binding Employees}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition />
                                                <ColumnDefinition />
                                            </Grid.ColumnDefinitions>
                                            <Border Grid.ColumnSpan="2"
                                                    Background="White"
                                                    BorderBrush="#002896"
                                                    BorderThickness="1" />
                                            <TextBlock Margin="5,0,0,0"
                                                       HorizontalAlignment="Left"
                                                       VerticalAlignment="Top"
                                                       Style="{StaticResource BodyTextBlackStyle}"
                                                       Text="{Binding Name}"
                                                       TextWrapping="Wrap" />
                                            <ItemsControl Grid.Column="1" ItemsSource="{Binding Languages}">
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <Grid Height="25">
                                                            <Border HorizontalAlignment="Stretch"
                                                                    Background="White"
                                                                    BorderBrush="#002896"
                                                                    BorderThickness="1" />
                                                            <TextBlock Margin="5,0,0,0"
                                                                       HorizontalAlignment="Left"
                                                                       VerticalAlignment="Top"
                                                                       Style="{StaticResource BodyTextBlackStyle}"
                                                                       Text="{Binding Name}"
                                                                       TextWrapping="Wrap" />
                                                        </Grid>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <StackPanel Grid.Row="3"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Margin="0,20,0,0"
                        Orientation="Horizontal">
                <TextBlock Style="{StaticResource BodyTextStyle}" Text="Languages count : " />
                <TextBlock Style="{StaticResource BodyTextStyle}" Text="{Binding Company.Departments, Converter={StaticResource CountConverter}, ConverterParameter={StaticResource LanguageCountParameter}}" />
            </StackPanel>
            <StackPanel Grid.Row="3"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Margin="0,50,0,0"
                        Orientation="Horizontal">
                <TextBlock Style="{StaticResource BodyTextStyle}" Text="Distinct Languages count : " />
                <TextBlock Style="{StaticResource BodyTextStyle}" Text="{Binding Company.Departments, Converter={StaticResource CountConverter}, ConverterParameter={StaticResource DistinctLanguageCountParameter}}" />
            </StackPanel>
        </Grid>
    </Grid>
</common:LayoutAwarePage>